#pragma once

#include <stdint.h>
#include <string>
#include <vector>

#include "util/status.h"
#include "util/cache/block_cache/block_file_accessor.h"

namespace hawking {
namespace indexlib {

enum class FSFileType {
    FSFT_UNKNOWN = 0,
    FSFT_MMAP,
    FSFT_BLOCK,
};

class FileReader {
public:
    FileReader(const std::string& file_path) : file_path_(file_path) {}
    virtual ~FileReader() = default;

    virtual Status Init() = 0;
    virtual Status Close() = 0;

    virtual ReturnValue<size_t> Read(uint8_t* buffer, size_t length, size_t offset) = 0;
    virtual ReturnValue<size_t> BatchRead(
        const std::vector<FilePart>& batch) = 0;

    virtual size_t Length() const = 0;
    const std::string& FilePath() const {
        return file_path_;
    }
    virtual FSFileType FileType() const = 0;

    virtual ReturnValue<size_t> Write(const uint8_t* buffer, size_t length, size_t offset) {
        return ReturnValue<size_t>{Status::NotSupport, 0};
    }

protected:
    std::string file_path_ = "";
};

}
}
